﻿using com.kmer.enums;
using com.kmer.models;
using System.Collections.Generic;

namespace com.kmer.interfaces
{
    public interface IFactory { }

    public interface IUserFactory : IFactory
    {
        /// <summary>
        /// 创建用户
        /// </summary>
        /// <param name="loginName">登录名称</param>
        /// <param name="nickName">昵称</param>
        /// <param name="pass">密码（MD5）</param>
        /// <param name="tel">手机</param>
        /// <param name="email">邮箱</param>
        /// <param name="comeFrom"></param>
        /// <param name="invId">邀请人ID</param>
        /// <returns></returns>
        User Create(string loginName, string nickName, string pass, string tel, string email, UserComeFrom comeFrom, int invId = 0);

        /// <summary>
        /// 登陆系统
        /// </summary>
        /// <param name="loginName">登陆名、电话、邮件</param>
        /// <param name="pass">密码（MD5）</param>
        User Login(string loginName, string pass);

        /// <summary>
        /// 退出登陆
        /// </summary>
        void LoginOut();

        /// <summary>
        /// 从OpenID获取用户ID
        /// </summary>
        /// <param name="openId"></param>
        /// <param name="ThirdPart">第三方类型
        /// 3 - 微信
        /// </param>
        /// <returns></returns>
        int GetUserIdByOpenId(string openId, int ThirdPart);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="cusId"></param>
        /// <returns></returns>
        bool CanIFreeBuy(int cusId);

        bool AmIVip(int cusId);
        IList<int> GetMyRankList(int cusId);
        /// <summary>
        /// 从用户ID获取OpenId
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="ThirdPart">第三方类型
        /// 3 - 微信
        /// </param>
        /// <returns></returns>
        string GetOpenIdByUserId(int userId, int ThirdPart);

        /// <summary>
        /// 通过用户ID获取用户
        /// </summary>
        /// <param name="cusId"></param>
        /// <returns></returns>
        User GetUserByUserID(int cusId);

        string GetUserName(int cusId, string prefix = "");

        /// <summary>
        /// 执行登陆操作
        /// </summary>
        /// <param name="user"></param>
        void DoLogin(User user);

        /// <summary>
        /// 获取用户的 刷新Token
        /// </summary>
        /// <param name="loginUser"></param>
        /// <returns></returns>
        string GetRefreshToken(User loginUser);

        /// <summary>
        /// 根据刷新Token获取用户ID
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        int GetUserIdFromRefres(string key);
    }
}
